package com.jinzecloud.reportapproval.manager;


import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jinzecloud.reportapproval.bean.RoleUserEntity;
import com.jinzecloud.reportapproval.mapper.RoleUserMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 角色员工 manager
 *
 * @Author 1024创新实验室-主任: 卓大
 * @Date 2022-04-08 21:53:04
 * @Wechat zhuoda1024
 * @Email lab1024@163.com
 * @Copyright  <a href="https://1024lab.net">1024创新实验室</a>
 */
@Service
public class RoleEmployeeManager extends ServiceImpl<RoleUserMapper, RoleUserEntity> {

    /**
     * 保存 角色员工
     *
     */
//    @Transactional(rollbackFor = Throwable.class)
//    public void saveRoleUser(Long roleId, List<RoleUserEntity> roleUserList) {
//        this.getBaseMapper().deleteByRoleId(roleId);
//        if (CollectionUtils.isNotEmpty(roleUserList)) {
//            this.saveBatch(roleUserList);
//        }
//    }

    @Transactional(rollbackFor = Throwable.class)
    public void saveRoleUser(List<RoleUserEntity> roList, Long roleUser) {
        this.getBaseMapper().deleteByRoleId(roleUser);
        if (CollectionUtils.isNotEmpty(roList)) {
            this.saveBatch(roList);
        }
    }
}
